<!DOCTYPE html>
<html>
<head>
    <title>Electromagnetic Induction Circuit</title>
</head>
<body>

<canvas id="physicsCanvas" width="400" height="400" style="border:1px solid #000000;"></canvas>

<script>
    const canvas = document.getElementById('physicsCanvas');
    const ctx = canvas.getContext('2d');

    // --- Style and Geometric Parameters ---
    const centerX = 200;
    const centerY = 200;
    const squareSize = 220;
    const left = centerX - squareSize / 2;
    const right = centerX + squareSize / 2;
    const top = centerY - squareSize / 2;
    const bottom = centerY + squareSize / 2;

    const bulbRadius = 13;
    const voltmeterRadius = 28;
    const mainLineWidth = 2;
    const voltmeterLineWidth = 3.5;

    // Helper function to draw a light bulb symbol (circle with a loop inside)
    function drawBulb(x, y, radius) {
        ctx.lineWidth = 1.5;
        // Draw the outer circle
        ctx.beginPath();
        ctx.arc(x, y, radius, 0, 2 * Math.PI);
        ctx.stroke();

        // Draw the filament loop
        ctx.beginPath();
        ctx.arc(x, y, radius * 0.6, 0.75 * Math.PI, 2.75 * Math.PI);
        ctx.stroke();
        ctx.lineWidth = mainLineWidth;
    }

    // --- Drawing Start ---

    // 1. Draw the magnetic field 'X' symbols
    ctx.font = "bold 28px Arial";
    ctx.fillStyle = 'black';
    ctx.textAlign = 'center';
    ctx.textBaseline = 'middle';
    
    // Positions are chosen to approximate the original image's layout
    ctx.fillText('X', centerX - 45, top + 40);
    ctx.fillText('X', centerX + 45, top + 40);
    ctx.fillText('X', left + 30, centerY);
    ctx.fillText('X', right - 30, centerY);
    ctx.fillText('X', centerX - 45, bottom - 40);
    ctx.fillText('X', centerX + 45, bottom - 40);

    // 2. Draw the square loop with resistors (bulbs)
    ctx.lineWidth = mainLineWidth;
    ctx.strokeStyle = 'black';

    // Top side with two bulbs
    const topBulb1_x = centerX - 50;
    const topBulb2_x = centerX + 50;
    ctx.beginPath();
    ctx.moveTo(left, top);
    ctx.lineTo(topBulb1_x - bulbRadius, top);
    ctx.moveTo(topBulb1_x + bulbRadius, top);
    ctx.lineTo(topBulb2_x - bulbRadius, top);
    ctx.moveTo(topBulb2_x + bulbRadius, top);
    ctx.lineTo(right, top);
    ctx.stroke();
    drawBulb(topBulb1_x, top, bulbRadius);
    drawBulb(topBulb2_x, top, bulbRadius);

    // Bottom side with one bulb
    const bottomBulb_x = centerX;
    ctx.beginPath();
    ctx.moveTo(left, bottom);
    ctx.lineTo(bottomBulb_x - bulbRadius, bottom);
    ctx.moveTo(bottomBulb_x + bulbRadius, bottom);
    ctx.lineTo(right, bottom);
    ctx.stroke();
    drawBulb(bottomBulb_x, bottom, bulbRadius);

    // Left and Right sides
    ctx.beginPath();
    ctx.moveTo(left, top);
    ctx.lineTo(left, bottom);
    ctx.moveTo(right, top);
    ctx.lineTo(right, bottom);
    ctx.stroke();

    // 3. Draw the 'R' labels
    ctx.font = "bold 22px Arial";
    ctx.textBaseline = 'alphabetic'; // Reset for normal text drawing
    ctx.fillText('R', topBulb1_x, top - 20);
    ctx.fillText('R', topBulb2_x, top - 20);
    ctx.fillText('R', bottomBulb_x, bottom + 32);


    // 4. Draw the voltmeter and its connections
    // Voltmeter connections (thicker lines)
    ctx.lineWidth = voltmeterLineWidth;
    const angle1 = Math.atan2(bottom - centerY, left - centerX); // to bottom-left corner
    const angle2 = Math.atan2(top - centerY, right - centerX);   // to top-right corner
    
    ctx.beginPath();
    ctx.moveTo(left, bottom);
    ctx.lineTo(centerX + voltmeterRadius * Math.cos(angle1), centerY + voltmeterRadius * Math.sin(angle1));
    ctx.stroke();

    ctx.beginPath();
    ctx.moveTo(right, top);
    ctx.lineTo(centerX + voltmeterRadius * Math.cos(angle2), centerY + voltmeterRadius * Math.sin(angle2));
    ctx.stroke();
    
    // Voltmeter circle
    ctx.lineWidth = voltmeterLineWidth;
    ctx.beginPath();
    ctx.arc(centerX, centerY, voltmeterRadius, 0, 2 * Math.PI);
    ctx.fillStyle = 'white'; // Fill to cover the diagonal lines inside
    ctx.fill();
    ctx.stroke();

    // Voltmeter 'V' label
    ctx.fillStyle = 'black';
    ctx.font = "bold 28px Arial";
    ctx.textAlign = 'center';
    ctx.textBaseline = 'middle';
    ctx.fillText('V', centerX, centerY + 2);

</script>

</body>
</html>